<template>
    <el-menu
        class="el-menu-demo"
        mode="horizontal"
        @select="handleSelect"
    >
        <el-submenu index="user">
             <template slot="title">{{this.$store.state.user.username}}</template>
            <el-menu-item index="logout">注销</el-menu-item>
        </el-submenu>
        <el-menu-item index="msg" disabled>消息中心</el-menu-item>
    </el-menu>
</template>
<script>
import { fetchPost } from '../../http';
export default {
    methods:{
        handleSelect(key, keyPath) {
            if(key == "logout") {
                fetchPost("/backUser/logout").then(() => {
                    this.$router.push("/login");
                });
            }
        }
    }
};
</script>
<style scoped>
</style>